package org.flower.service.impl;

import org.flower.dao.AdminUserDao;
import org.flower.dao.CommodityDetailsDao;
import org.flower.dao.OrderDao;
import org.flower.dao.UserDao;
import org.flower.dao.impl.AdminUserDaoImpl;
import org.flower.dao.impl.CommodityDetailsDaoImpl;
import org.flower.dao.impl.OrderDaoImpl;
import org.flower.dao.impl.UserDaoImpl;
import org.flower.entity.Statistics;
import org.flower.service.StatisticsService;

import java.util.List;

/**
 * @author Aizen
 */
public class StatisticsServiceImpl implements StatisticsService {
    UserDao userDao = new UserDaoImpl();
    CommodityDetailsDao commodityDetailsDao = new CommodityDetailsDaoImpl();
    AdminUserDao adminUserDao = new AdminUserDaoImpl();
    OrderDao orderDao = new OrderDaoImpl();
    @Override
    public Statistics getStatistics() {
        Statistics statistics = new Statistics();

        /**
         * 用户数据
         */
        //获取日增用户
        int dayAddUser = userDao.getDayAddUser();
        statistics.setAddUser(dayAddUser);
        //获取总用户
        int allUserCount = userDao.getAllUserCount();
        statistics.setSumUser(allUserCount);
        //获取周用户量
        List<Integer> zhouDate = userDao.getZhouDate();
        statistics.setZhouUser(zhouDate);


        /**
         * 订单数据
         */
        //获取日增订单
        int dayAddOrder = orderDao.findDayAddOrder();
        statistics.setAddOder(dayAddOrder);
        //获取总订单
        int sumOrder = orderDao.findSumOrder();
        statistics.setSumOder(sumOrder);
        //获取周订单
        List<Integer> zhouOrder = orderDao.getZhouOrder();
        statistics.setZhouOder(zhouOrder);


        /**
         * 商品数据
         */
        //获取日增商品
        int dayAddGoodsCount = commodityDetailsDao.getDayAddGoodsCount();
        statistics.setAddGoods(dayAddGoodsCount);
        //获取总商品
        int totalCount = commodityDetailsDao.getTotalCount();
        statistics.setSumGoods(totalCount);
        //获取周商品数据
        List<Integer> zhouGoods = commodityDetailsDao.getZhouGoods();
        statistics.setZhouGoods(zhouGoods);

        /**
         * 管理员数据
         */
        //获取日增管理员
        int dayAddAdminUser = adminUserDao.getDayAddAdminUser();
        statistics.setAddAdminUser(dayAddAdminUser);
        //获取总管理员
        int allAdminUser = adminUserDao.getAllAdminUser();
        statistics.setSumAdminUser(allAdminUser);
        //获取周管理员
        List<Integer> zhouAdminUser = adminUserDao.getZhouAdminUser();
        statistics.setZhouAdminUser(zhouAdminUser);

        return statistics;
    }
}
